extends Node2D
class_name Explosion

# 节点引用
@onready var sprite = $Sprite2D
@onready var animation_player = $AnimationPlayer
@onready var timer = $Timer

func _ready():
	# 连接计时器信号
	timer.timeout.connect(_on_timer_timeout)
	
	# 创建简单的缩放动画
	create_animation()

func create_animation():
	# 创建动画资源
	var animation = Animation.new()
	var track_index = animation.add_track(Animation.TYPE_SCALE_3D)
	
	# 设置动画长度
	animation.length = 0.5
	
	# 添加关键帧
	animation.track_insert_key(track_index, 0.0, Vector3(0.1, 0.1, 1.0))
	animation.track_insert_key(track_index, 0.2, Vector3(1.2, 1.2, 1.0))
	animation.track_insert_key(track_index, 0.5, Vector3(0.0, 0.0, 1.0))
	
	# 创建动画库
	var animation_library = AnimationLibrary.new()
	animation_library.add_animation("explode", animation)
	
	# 添加到动画播放器
	animation_player.add_animation_library("default", animation_library)
	animation_player.play("explode")

func _on_timer_timeout():
	queue_free()
